<!-- recruit表单弹窗 -->
<form id="recruit-form" lay-filter="recruit-form" class="layui-form model-form">
    <input name="id" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label">职位名称</label>
        <div class="layui-input-block">
            <input name="recruitName" placeholder="请输入职位名称" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司位置</label>
        <div class="layui-input-block">
            <input name="address" placeholder="请输入公司位置" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">工作经验</label>
        <div class="layui-input-block">
            <input name="workExperience" placeholder="请输入工作经验" type="text" class="layui-input" lay-verify="required"
                   required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">学历</label>
        <div class="layui-input-block">
            <input name="education" placeholder="请输入学历" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">技能</label>
        <div class="layui-input-block">
            <input name="skill" placeholder="请输入职位技能" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司名称</label>
        <div class="layui-input-block">
            <select id="com" name="companyName" filter lay-verify="required"></select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">工资</label>
        <div class="layui-input-block">
            <input id="wage" name="wage" placeholder="请输入工资，最低工资请填5000"  type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">岗位要求</label>
        <div class="layui-input-block">
            <input name="jobRequirements" placeholder="请输入岗位要求" type="text" class="layui-input" maxlength="40"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">岗位职责</label>
        <div class="layui-input-block">
            <input name="jobResponsibilities" placeholder="请输入岗位职责" type="text" class="layui-input" maxlength="40"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">上班时间</label>
        <div class="layui-input-block">
            <input name="workRequirements" placeholder="请输入上班时间" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职位福利</label>
        <div class="layui-input-block">
            <input name="jobBenefits" placeholder="请输入职位福利" type="text" class="layui-input" maxlength="30"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司信息</label>
        <div class="layui-input-block">
            <input name="companyInformation" placeholder="请输入公司信息" type="text" class="layui-input" maxlength="40"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司人数</label>
        <div class="layui-input-block">
            <input name="companyTechniciansNum" placeholder="请输入公司人数" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">咨询负责人</label>
        <div class="layui-input-block">
            <input name="personnel" placeholder="请输入咨询负责人" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="sex" value="0" title="男" checked/>
            <input type="radio" name="sex" value="1" title="女"/>
        </div>
    </div>

    <div class="layui-form-item model-form-footer">
        <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
        <button class="layui-btn" lay-filter="recruit-form-submit" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'admin', 'form', 'formSelects','config'], function () {

        var layer = layui.layer;
        var admin = layui.admin;
        var form = layui.form;
        var config = layui.config;
        var formSelects = layui.formSelects;


        // form.render('radio');


        // 回显user数据
        var recruit = admin.getTempData('t_recruit');
        if (recruit) {
            form.val('recruit-form', recruit);
        }
// 表单提交事件
        console.log("asdsasd")
        var token = JSON.parse(layui.data("easyweb").token).access_token;
        let html= '';
        $.ajax({
            url:config.base_server + "api-company/company/selectCompany",
            data:{access_token:token,page:1,limit:1000},
            dataType:"json",
            type:"post",
            success: function (data){
                if (data.code ==0){
                    for(let i = 0;i<data.data.length;i++){
                        html = html + '<option value="'+data.data[i].id+'">'
                            +data.data[i].companyName+'</option>'
                    }
                    $("#com").html(html);
                    form.render();
                }
            }
        });

        form.on('submit(recruit-form-submit)', function (data) {
            layer.load(2);

            if (data.field.id!=null && data.field.id!=''){
                admin.req('api-recruit/recruit/updateRecruitInformation', JSON.stringify(data.field), function (data) {
                    layer.closeAll('loading');
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 500});
                        admin.finishPopupCenter();
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 500});
                    }
                }, 'POST');
                return false;
            }else{
                admin.req('api-recruit/recruit/addRecruitInformation', JSON.stringify(data.field), function (data) {
                    layer.closeAll('loading');
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 500});
                        admin.finishPopupCenter();
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 500});
                    }
                }, 'POST');
                return false;
            }

        });
    });
</script>